<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript">
  $(function() {
    parent.$.messager.progress('close');
    $('#departmentId').combotree({
      url : '${pageContext.request.contextPath}/admin/organization/organizationComboTree',
      parentField : 'pid',
      lines : true,
      panelHeight : 'auto',
      onLoadSuccess : function() {
        //回填上级部门
        $('#departmentId').combotree('setValue', '${organization.orgPid}');
        parent.$.messager.progress('close');
      }
    });

    $('#form').form({
      url : '${pageContext.request.contextPath}/admin/organization/edit',
      onSubmit : function() {
        parent.$.messager.progress({
          title : '提示',
          text : '数据处理中，请稍后....'
        });
        var isValid = $(this).form('validate');
        if (!isValid) {
          parent.$.messager.progress('close');
        }
        return isValid;
      },
      success : function(result) {
        parent.$.messager.progress('close');
        result = $.parseJSON(result);
        if (result.success) {
          parent.$.messager.alert('成功', result.msg, 'info', function() {
            parent.$.modalDialog.openner_treeGrid.treegrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_treeGrid这个对象，是因为role.jsp页面预定义好了
            parent.$.modalDialog.handler.dialog('close');
          });
        } else {
          parent.$.messager.alert('错误', result.msg, 'error');
        }
      }
    });
  });
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
  <div data-options="region:'center',border:false" title="" style="overflow: hidden;">
    <form id="form" method="post">
      <table class="table table-hover table-condensed">
        <tr>
          <td>组织机构名：</td>
          <td><input type="hidden" name="id" value="${organization.id}" /> <input
            name="orgName" type="text" type="text" value="${organization.orgName}"
            class="easyui-validatebox span2" data-options="width: 150,required:true" /></td>
          <td>负责人：</td>
          <td><input name="orgLeader" type="text" type="text" value="${organization.orgLeader}"
            class="easyui-validatebox span2" data-options="width: 150" /></td>
        </tr>
        <tr>
          <td>组织机构地址：</td>
          <td><input name="orgAddress" type="text" value="${organization.orgAddress}"
            class="easyui-validatebox span2" /></td>
          <td>联系电话：</td>
          <td><input name="orgPhone" type="text" type="text" value="${organization.orgPhone}"
            class="easyui-validatebox span2" data-options="width: 150" /></td>
        </tr>
        <tr>
          <td>状态：</td>
          <td><select class="easyui-combobox" name="orgStatus" data-options="width: 150"><option
                value="1">使用</option>
              <option value="0">废弃</option></select></td>
          <td>上级部门：</td>
          <td><select id="departmentId" name="orgPid" style="width: 140px; height: 29px;"></select><img
            src="${pageContext.request.contextPath}/resources/css/images/extjs_icons/cut_red.png"
            onclick="$('#departmentId').combotree('clear');" /></td>
        </tr>
        <tr>
          <td>描述：</td>
          <td colspan="3"><textarea name="orgDesc" rows="2" cols="" class="span5"
              onKeyUp="if(this.value.length>80){this.value=this.value.substring(0,80);}"> ${organization.orgDesc}</textarea></td>
        </tr>
      </table>
    </form>
  </div>
</div>
